package UdpServerAndClient;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpDictServer extends UdpEchoServer{
    private Map<String, String> dictMap = new HashMap<>();
    public UdpDictServer(int port) throws SocketException {
        super(port);
        dictMap.put("hello","你好");
        dictMap.put("cat","小猫");
        dictMap.put("dog","小狗");
        dictMap.put("pig","小猪");
    }
    @Override
    public String process(String request){
        return dictMap.getOrDefault(request,"没有查到该词汇！");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer dictServer = new UdpDictServer(9090);
        dictServer.start();
    }


}
